package models

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB
var err error

func Init() {
	DB, err = gorm.Open(mysql.Open("root:89B158B4DAFE6F5461878D26EA49B100@tcp(14.103.158.217:3306)/MyLiftLog?charset=utf8&parseTime=True&loc=Local"))
	if err != nil {
		fmt.Println("数据库连接成功")
		return
	}
	err = DB.AutoMigrate(&Good{}, &Activity{}, &Shop{}, &GImage{}, &SImage{}, &AImage{}, &User{})
	if err != nil {
		fmt.Println("数据表迁移失败")
		return
	}
	fmt.Println("预处理完成")
}
